import { transform } from "@svgr/core"
import { readFileSync, writeFileSync } from "fs"
import { format } from "prettier"

const html = String.raw

/* -----------------------------------------------------------------------------
 *  Edit code here
 * -----------------------------------------------------------------------------*/

const name = "ScrollArea"

// prettier-ignore
const svgCode = html`
<svg width="1456" height="812" viewBox="0 0 1456 812" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="352" y="120" width="753" height="608" fill="#1C4D37"/>
<rect x="397" y="152" width="637" height="576" fill="#287753"/>
<rect width="30" height="548" rx="15" transform="matrix(-1 0 0 1 1082 152)" fill="#287753"/>
<rect width="30" height="214" rx="15" transform="matrix(-1 0 0 1 1082 152)" fill="white"/>
<rect x="326.36" y="100.36" width="803.28" height="642.28" stroke="#C1FFDF" stroke-width="2.71984" stroke-dasharray="10.88 10.88"/>
<path d="M176.328 173V157.18H179.257L179.634 163.27L179.33 162.429C179.397 161.791 179.523 161.144 179.707 160.486C179.9 159.829 180.171 159.225 180.519 158.674C180.876 158.123 181.331 157.683 181.882 157.355C182.442 157.016 183.124 156.847 183.926 156.847C184.119 156.847 184.313 156.857 184.506 156.876C184.699 156.895 184.878 156.929 185.043 156.977V160.631C184.714 160.525 184.361 160.457 183.984 160.428C183.617 160.39 183.278 160.37 182.969 160.37C182.592 160.37 182.186 160.448 181.751 160.602C181.316 160.747 180.915 160.97 180.548 161.269C180.18 161.569 179.914 161.941 179.75 162.386V173H176.328ZM193.564 173.218C192.104 173.218 190.833 172.903 189.75 172.275C188.668 171.647 187.827 170.723 187.227 169.505C186.628 168.278 186.328 166.775 186.328 164.996C186.328 163.314 186.642 161.864 187.271 160.646C187.909 159.428 188.779 158.495 189.881 157.847C190.983 157.19 192.23 156.861 193.622 156.861C195.13 156.861 196.42 157.19 197.493 157.847C198.576 158.495 199.407 159.428 199.987 160.646C200.567 161.864 200.857 163.314 200.857 164.996C200.857 166.775 200.533 168.278 199.886 169.505C199.248 170.723 198.378 171.647 197.276 172.275C196.174 172.903 194.936 173.218 193.564 173.218ZM193.622 170.303C194.733 170.303 195.642 169.887 196.348 169.056C197.053 168.225 197.406 166.871 197.406 164.996C197.406 163.256 197.063 161.951 196.377 161.081C195.69 160.211 194.753 159.776 193.564 159.776C192.452 159.776 191.543 160.206 190.838 161.066C190.142 161.927 189.794 163.237 189.794 164.996C189.794 166.784 190.147 168.118 190.852 168.998C191.568 169.868 192.491 170.303 193.622 170.303ZM210.358 173.218C208.898 173.218 207.627 172.903 206.544 172.275C205.462 171.647 204.621 170.723 204.021 169.505C203.422 168.278 203.122 166.775 203.122 164.996C203.122 163.314 203.436 161.864 204.065 160.646C204.703 159.428 205.573 158.495 206.675 157.847C207.777 157.19 209.024 156.861 210.416 156.861C211.924 156.861 213.214 157.19 214.287 157.847C215.37 158.495 216.201 159.428 216.781 160.646C217.361 161.864 217.651 163.314 217.651 164.996C217.651 166.775 217.327 168.278 216.68 169.505C216.042 170.723 215.172 171.647 214.07 172.275C212.968 172.903 211.73 173.218 210.358 173.218ZM210.416 170.303C211.527 170.303 212.436 169.887 213.142 169.056C213.847 168.225 214.2 166.871 214.2 164.996C214.2 163.256 213.857 161.951 213.171 161.081C212.484 160.211 211.547 159.776 210.358 159.776C209.246 159.776 208.337 160.206 207.632 161.066C206.936 161.927 206.588 163.237 206.588 164.996C206.588 166.784 206.941 168.118 207.646 168.998C208.362 169.868 209.285 170.303 210.416 170.303ZM225.577 173.232C224.32 173.232 223.339 172.913 222.633 172.275C221.937 171.627 221.589 170.704 221.589 169.505V161.501C221.589 161.182 221.657 160.897 221.792 160.646C221.927 160.385 222.126 160.221 222.387 160.153L221.589 157.804V157.383L222.358 152.642H224.968V168.65C224.968 169.211 225.088 169.602 225.33 169.824C225.581 170.047 226.045 170.158 226.722 170.158C227.157 170.158 227.558 170.158 227.926 170.158C228.293 170.148 228.626 170.139 228.926 170.129V173.044C228.423 173.131 227.872 173.184 227.273 173.203C226.674 173.222 226.108 173.232 225.577 173.232ZM219.516 160.153V157.18H228.955V160.153H219.516Z" fill="white"/>
<path d="M115.105 319L109.595 303.18H113.481L115.511 310.517L116.888 315.636H117.019L118.396 310.532L120.426 303.18H124.312L118.802 319H115.105ZM126.796 319V303.18H130.262L130.218 319H126.796ZM128.551 300.831C127.923 300.831 127.391 300.614 126.956 300.179C126.521 299.734 126.303 299.169 126.303 298.482C126.303 297.806 126.521 297.255 126.956 296.829C127.391 296.404 127.923 296.191 128.551 296.191C129.16 296.191 129.682 296.404 130.117 296.829C130.562 297.255 130.784 297.806 130.784 298.482C130.784 299.169 130.562 299.734 130.117 300.179C129.682 300.614 129.16 300.831 128.551 300.831ZM140.905 319.218C139.377 319.218 138.053 318.908 136.932 318.289C135.82 317.661 134.964 316.738 134.365 315.52C133.766 314.302 133.466 312.808 133.466 311.039C133.466 309.319 133.78 307.849 134.409 306.631C135.047 305.404 135.921 304.471 137.033 303.833C138.145 303.185 139.421 302.861 140.861 302.861C142.282 302.861 143.495 303.142 144.501 303.702C145.516 304.263 146.289 305.094 146.821 306.196C147.352 307.289 147.618 308.632 147.618 310.227C147.618 310.537 147.608 310.793 147.589 310.996C147.579 311.199 147.565 311.441 147.546 311.721H136.874C136.961 313.335 137.357 314.524 138.063 315.288C138.768 316.042 139.633 316.419 140.658 316.419C141.615 316.419 142.345 316.216 142.848 315.81C143.36 315.394 143.689 314.93 143.834 314.418H147.14C147.053 315.433 146.734 316.303 146.183 317.028C145.632 317.743 144.902 318.289 143.993 318.666C143.094 319.034 142.065 319.218 140.905 319.218ZM138.44 309.386H144.211C144.182 308.226 143.901 307.332 143.37 306.704C142.838 306.066 141.963 305.747 140.745 305.747C139.479 305.747 138.536 306.172 137.918 307.023C137.299 307.864 136.951 309.029 136.874 310.517C136.951 310.082 137.115 309.788 137.367 309.633C137.618 309.469 137.976 309.386 138.44 309.386ZM153.727 319L148.927 303.18H152.683L154.655 311.039L155.626 316.085L155.8 316.1L156.583 311.025L158.483 303.18H162.789L164.66 311.054L165.428 316.259L165.646 316.245L166.632 311.054L168.604 303.18H172.345L167.56 319H163.558L161.658 311.46L160.774 306.878H160.527L159.599 311.474L157.714 319H153.727ZM182.511 319.174C181.467 319.174 180.635 319 180.017 318.652C179.398 318.304 178.944 317.898 178.654 317.434C178.364 316.96 178.18 316.545 178.103 316.187L176.943 316.245L178.291 315.099C178.359 315.341 178.509 315.578 178.741 315.81C178.973 316.032 179.311 316.216 179.756 316.361C180.2 316.496 180.747 316.564 181.394 316.564C182.477 316.564 183.366 316.143 184.062 315.302C184.768 314.461 185.121 313.055 185.121 311.083C185.121 309.382 184.792 308.077 184.135 307.168C183.477 306.25 182.636 305.79 181.612 305.79C180.887 305.79 180.287 305.892 179.814 306.095C179.35 306.298 178.997 306.535 178.755 306.805C178.514 307.076 178.359 307.318 178.291 307.53V306.443C178.311 306.124 178.393 305.766 178.538 305.37C178.692 304.964 178.939 304.572 179.277 304.195C179.625 303.809 180.08 303.495 180.64 303.253C181.211 303.002 181.916 302.876 182.757 302.876C184.033 302.876 185.106 303.219 185.976 303.905C186.846 304.592 187.504 305.534 187.948 306.733C188.403 307.922 188.63 309.275 188.63 310.793C188.63 312.195 188.456 313.422 188.108 314.476C187.769 315.52 187.305 316.39 186.716 317.086C186.136 317.782 185.483 318.304 184.758 318.652C184.033 319 183.284 319.174 182.511 319.174ZM174.884 324.844V303.18H178.248L178.291 305.355V315.23L178.103 316.187L178.291 319.015V324.844H174.884ZM198.463 319.218C197.004 319.218 195.732 318.903 194.65 318.275C193.567 317.647 192.726 316.723 192.127 315.505C191.527 314.278 191.228 312.775 191.228 310.996C191.228 309.314 191.542 307.864 192.17 306.646C192.808 305.428 193.678 304.495 194.78 303.847C195.882 303.19 197.129 302.861 198.521 302.861C200.029 302.861 201.32 303.19 202.393 303.847C203.475 304.495 204.307 305.428 204.887 306.646C205.467 307.864 205.757 309.314 205.757 310.996C205.757 312.775 205.433 314.278 204.785 315.505C204.147 316.723 203.277 317.647 202.175 318.275C201.073 318.903 199.836 319.218 198.463 319.218ZM198.521 316.303C199.633 316.303 200.542 315.887 201.247 315.056C201.953 314.225 202.306 312.871 202.306 310.996C202.306 309.256 201.963 307.951 201.276 307.081C200.59 306.211 199.652 305.776 198.463 305.776C197.352 305.776 196.443 306.206 195.737 307.066C195.041 307.927 194.693 309.237 194.693 310.996C194.693 312.784 195.046 314.118 195.752 314.998C196.467 315.868 197.39 316.303 198.521 316.303ZM209.01 319V303.18H211.939L212.316 309.27L212.011 308.429C212.079 307.791 212.204 307.144 212.388 306.486C212.581 305.829 212.852 305.225 213.2 304.674C213.558 304.123 214.012 303.683 214.563 303.355C215.124 303.016 215.805 302.847 216.608 302.847C216.801 302.847 216.994 302.857 217.188 302.876C217.381 302.895 217.56 302.929 217.724 302.977V306.631C217.395 306.525 217.043 306.457 216.666 306.428C216.298 306.39 215.96 306.37 215.651 306.37C215.274 306.37 214.868 306.448 214.433 306.602C213.998 306.747 213.596 306.97 213.229 307.269C212.862 307.569 212.596 307.941 212.432 308.386V319H209.01ZM225.577 319.232C224.32 319.232 223.339 318.913 222.633 318.275C221.937 317.627 221.589 316.704 221.589 315.505V307.501C221.589 307.182 221.657 306.897 221.792 306.646C221.927 306.385 222.126 306.221 222.387 306.153L221.589 303.804V303.383L222.358 298.642H224.968V314.65C224.968 315.211 225.088 315.602 225.33 315.824C225.581 316.047 226.045 316.158 226.722 316.158C227.157 316.158 227.558 316.158 227.926 316.158C228.293 316.148 228.626 316.139 228.926 316.129V319.044C228.423 319.131 227.872 319.184 227.273 319.203C226.674 319.222 226.108 319.232 225.577 319.232ZM219.516 306.153V303.18H228.955V306.153H219.516Z" fill="white"/>
<path d="M134.834 485.276C133.268 485.276 131.924 484.932 130.803 484.246C129.681 483.55 128.821 482.583 128.222 481.346C127.632 480.109 127.337 478.673 127.337 477.039C127.337 475.319 127.642 473.849 128.251 472.631C128.86 471.413 129.705 470.485 130.788 469.847C131.871 469.2 133.118 468.876 134.529 468.876C135.931 468.876 137.105 469.137 138.053 469.659C139.01 470.171 139.725 470.862 140.199 471.732C140.672 472.593 140.89 473.555 140.851 474.618H137.56C137.55 474.193 137.482 473.806 137.357 473.458C137.231 473.1 137.042 472.801 136.791 472.559C136.549 472.308 136.24 472.114 135.863 471.979C135.486 471.844 135.046 471.776 134.544 471.776C133.19 471.766 132.228 472.23 131.658 473.168C131.097 474.106 130.817 475.372 130.817 476.967C130.817 478.784 131.155 480.142 131.832 481.041C132.518 481.931 133.587 482.38 135.037 482.39C135.375 482.39 135.742 482.293 136.139 482.1C136.545 481.897 136.888 481.612 137.168 481.244C137.458 480.867 137.598 480.418 137.589 479.896H140.851C140.89 481.008 140.624 481.965 140.054 482.767C139.493 483.569 138.749 484.188 137.821 484.623C136.893 485.058 135.897 485.276 134.834 485.276ZM150.149 485.218C148.689 485.218 147.418 484.903 146.335 484.275C145.253 483.647 144.412 482.723 143.812 481.505C143.213 480.278 142.913 478.775 142.913 476.996C142.913 475.314 143.227 473.864 143.856 472.646C144.494 471.428 145.364 470.495 146.466 469.847C147.568 469.19 148.815 468.861 150.207 468.861C151.715 468.861 153.005 469.19 154.078 469.847C155.161 470.495 155.992 471.428 156.572 472.646C157.152 473.864 157.442 475.314 157.442 476.996C157.442 478.775 157.118 480.278 156.471 481.505C155.833 482.723 154.963 483.647 153.861 484.275C152.759 484.903 151.521 485.218 150.149 485.218ZM150.207 482.303C151.318 482.303 152.227 481.887 152.933 481.056C153.638 480.225 153.991 478.871 153.991 476.996C153.991 475.256 153.648 473.951 152.962 473.081C152.275 472.211 151.338 471.776 150.149 471.776C149.037 471.776 148.128 472.206 147.423 473.066C146.727 473.927 146.379 475.237 146.379 476.996C146.379 478.784 146.732 480.118 147.437 480.998C148.153 481.868 149.076 482.303 150.207 482.303ZM160.78 485V469.18H163.709L164.086 475.14L163.84 473.936C163.956 473.066 164.183 472.245 164.521 471.471C164.869 470.688 165.386 470.055 166.073 469.572C166.759 469.089 167.677 468.847 168.828 468.847C170.326 468.847 171.486 469.316 172.308 470.253C173.129 471.181 173.54 472.602 173.54 474.516V485H170.118V475.705C170.118 474.797 170.026 474.067 169.843 473.516C169.669 472.965 169.384 472.569 168.987 472.327C168.591 472.076 168.064 471.95 167.407 471.95C166.691 471.95 166.039 472.163 165.449 472.588C164.869 473.004 164.454 473.477 164.202 474.009V485H160.78ZM181.963 485.232C180.707 485.232 179.725 484.913 179.02 484.275C178.324 483.627 177.976 482.704 177.976 481.505V473.501C177.976 473.182 178.043 472.897 178.179 472.646C178.314 472.385 178.512 472.221 178.773 472.153L177.976 469.804V469.383L178.744 464.642H181.354V480.65C181.354 481.211 181.475 481.602 181.717 481.824C181.968 482.047 182.432 482.158 183.109 482.158C183.544 482.158 183.945 482.158 184.312 482.158C184.68 482.148 185.013 482.139 185.313 482.129V485.044C184.81 485.131 184.259 485.184 183.66 485.203C183.06 485.222 182.495 485.232 181.963 485.232ZM175.902 472.153V469.18H185.342V472.153H175.902ZM194.6 485.218C193.073 485.218 191.748 484.908 190.627 484.289C189.515 483.661 188.66 482.738 188.06 481.52C187.461 480.302 187.161 478.808 187.161 477.039C187.161 475.319 187.476 473.849 188.104 472.631C188.742 471.404 189.617 470.471 190.728 469.833C191.84 469.185 193.116 468.861 194.556 468.861C195.977 468.861 197.191 469.142 198.196 469.702C199.211 470.263 199.984 471.094 200.516 472.196C201.048 473.289 201.313 474.632 201.313 476.227C201.313 476.537 201.304 476.793 201.284 476.996C201.275 477.199 201.26 477.441 201.241 477.721H190.569C190.656 479.335 191.052 480.524 191.758 481.288C192.464 482.042 193.329 482.419 194.353 482.419C195.31 482.419 196.04 482.216 196.543 481.81C197.055 481.394 197.384 480.93 197.529 480.418H200.835C200.748 481.433 200.429 482.303 199.878 483.028C199.327 483.743 198.597 484.289 197.688 484.666C196.789 485.034 195.76 485.218 194.6 485.218ZM192.135 475.386H197.906C197.877 474.226 197.597 473.332 197.065 472.704C196.533 472.066 195.658 471.747 194.44 471.747C193.174 471.747 192.232 472.172 191.613 473.023C190.994 473.864 190.646 475.029 190.569 476.517C190.646 476.082 190.811 475.788 191.062 475.633C191.313 475.469 191.671 475.386 192.135 475.386ZM204.393 485V469.18H207.322L207.699 475.14L207.453 473.936C207.569 473.066 207.796 472.245 208.134 471.471C208.482 470.688 209 470.055 209.686 469.572C210.372 469.089 211.291 468.847 212.441 468.847C213.939 468.847 215.099 469.316 215.921 470.253C216.743 471.181 217.153 472.602 217.153 474.516V485H213.731V475.705C213.731 474.797 213.64 474.067 213.456 473.516C213.282 472.965 212.997 472.569 212.6 472.327C212.204 472.076 211.677 471.95 211.02 471.95C210.305 471.95 209.652 472.163 209.062 472.588C208.482 473.004 208.067 473.477 207.815 474.009V485H204.393ZM225.577 485.232C224.32 485.232 223.339 484.913 222.633 484.275C221.937 483.627 221.589 482.704 221.589 481.505V473.501C221.589 473.182 221.657 472.897 221.792 472.646C221.927 472.385 222.126 472.221 222.387 472.153L221.589 469.804V469.383L222.358 464.642H224.968V480.65C224.968 481.211 225.088 481.602 225.33 481.824C225.581 482.047 226.045 482.158 226.722 482.158C227.157 482.158 227.558 482.158 227.926 482.158C228.293 482.148 228.626 482.139 228.926 482.129V485.044C228.423 485.131 227.872 485.184 227.273 485.203C226.674 485.222 226.108 485.232 225.577 485.232ZM219.516 472.153V469.18H228.955V472.153H219.516Z" fill="white"/>
<path d="M1241.02 276.232C1239.76 276.232 1238.78 275.913 1238.07 275.275C1237.38 274.627 1237.03 273.704 1237.03 272.505V264.501C1237.03 264.182 1237.1 263.897 1237.23 263.646C1237.37 263.385 1237.57 263.221 1237.83 263.153L1237.03 260.804V260.383L1237.8 255.642H1240.41V271.65C1240.41 272.211 1240.53 272.602 1240.77 272.824C1241.02 273.047 1241.49 273.158 1242.16 273.158C1242.6 273.158 1243 273.158 1243.37 273.158C1243.73 273.148 1244.07 273.139 1244.37 273.129V276.044C1243.86 276.131 1243.31 276.184 1242.71 276.203C1242.12 276.222 1241.55 276.232 1241.02 276.232ZM1234.96 263.153V260.18H1244.4V263.153H1234.96ZM1247.59 276V253.438H1250.98V260.18L1250.75 264.69L1250.88 265.966L1250.71 264.936C1250.82 264.066 1251.04 263.245 1251.37 262.471C1251.71 261.688 1252.22 261.055 1252.9 260.572C1253.58 260.089 1254.5 259.847 1255.65 259.847C1257.15 259.847 1258.3 260.316 1259.12 261.253C1259.94 262.181 1260.35 263.602 1260.35 265.516V276H1256.91V266.705C1256.91 265.362 1256.71 264.4 1256.32 263.82C1255.92 263.24 1255.21 262.95 1254.19 262.95C1253.48 262.95 1252.84 263.187 1252.27 263.66C1251.71 264.124 1251.29 264.642 1251 265.212V276H1247.59ZM1268.79 276.319C1267.42 276.319 1266.32 275.84 1265.48 274.883C1264.65 273.926 1264.24 272.554 1264.24 270.765V260.166H1267.66V269.852C1267.66 270.625 1267.75 271.263 1267.92 271.766C1268.09 272.269 1268.37 272.636 1268.75 272.868C1269.12 273.1 1269.61 273.216 1270.21 273.216C1270.94 273.216 1271.59 273.008 1272.17 272.592C1272.76 272.167 1273.17 271.689 1273.42 271.157V260.166H1276.84V276H1273.92L1273.53 270.026L1273.79 271.229C1273.68 272.099 1273.45 272.921 1273.1 273.694C1272.76 274.468 1272.24 275.101 1271.55 275.594C1270.86 276.077 1269.94 276.319 1268.79 276.319ZM1281.15 276V260.18H1284.09L1284.47 266.14L1284.22 264.936C1284.34 264.066 1284.57 263.245 1284.9 262.471C1285.24 261.688 1285.75 261.055 1286.44 260.572C1287.13 260.089 1288.04 259.847 1289.18 259.847C1290.45 259.847 1291.47 260.209 1292.24 260.934C1293.02 261.65 1293.51 262.752 1293.69 264.24L1293.76 264.472V276H1290.33V266.705C1290.33 265.797 1290.24 265.067 1290.07 264.516C1289.89 263.965 1289.62 263.569 1289.24 263.327C1288.87 263.076 1288.38 262.95 1287.77 262.95C1287.06 262.95 1286.41 263.163 1285.83 263.588C1285.25 264.004 1284.84 264.477 1284.58 265.009V276H1281.15ZM1299.51 276V266.705C1299.51 265.797 1299.42 265.067 1299.24 264.516C1299.07 263.965 1298.79 263.569 1298.42 263.327C1298.05 263.076 1297.56 262.95 1296.95 262.95C1296.24 262.95 1295.59 263.163 1295.01 263.588C1294.43 264.004 1294.01 264.477 1293.76 265.009L1293.73 266.14L1293.5 265.197C1293.6 264.337 1293.81 263.501 1294.13 262.689C1294.45 261.867 1294.96 261.191 1295.63 260.659C1296.31 260.118 1297.22 259.847 1298.36 259.847C1299.79 259.847 1300.91 260.316 1301.72 261.253C1302.54 262.181 1302.94 263.602 1302.94 265.516V276H1299.51ZM1314.82 276.174C1313.77 276.174 1312.94 276 1312.32 275.652C1311.7 275.304 1311.25 274.898 1310.96 274.434C1310.67 273.96 1310.48 273.545 1310.41 273.187L1309.65 272.505L1310.6 272.099C1310.66 272.341 1310.81 272.578 1311.05 272.81C1311.29 273.032 1311.63 273.216 1312.06 273.361C1312.51 273.496 1313.05 273.564 1313.7 273.564C1314.78 273.564 1315.68 273.143 1316.38 272.302C1317.09 271.461 1317.44 270.065 1317.44 268.112C1317.44 266.353 1317.11 265.028 1316.44 264.139C1315.78 263.24 1314.94 262.79 1313.92 262.79C1313.19 262.79 1312.59 262.892 1312.12 263.095C1311.65 263.298 1311.3 263.535 1311.06 263.805C1310.82 264.076 1310.66 264.318 1310.6 264.53L1310.38 264.327L1310.61 263.776C1310.66 263.042 1310.84 262.384 1311.16 261.804C1311.49 261.215 1311.97 260.746 1312.61 260.398C1313.26 260.05 1314.08 259.876 1315.06 259.876C1316.34 259.876 1317.41 260.219 1318.28 260.905C1319.15 261.582 1319.81 262.515 1320.25 263.704C1320.71 264.883 1320.93 266.246 1320.93 267.793C1320.93 269.195 1320.76 270.422 1320.41 271.476C1320.07 272.52 1319.61 273.39 1319.02 274.086C1318.44 274.782 1317.79 275.304 1317.06 275.652C1316.34 276 1315.59 276.174 1314.82 276.174ZM1307.22 276L1307.2 253.438H1310.61V260.615L1310.63 272.433L1310.87 272.984L1310.6 273.549L1310.45 276H1307.22Z" fill="white"/>
<path d="M1241.53 491.247C1240.34 491.247 1239.27 491.073 1238.34 490.724C1237.41 490.376 1236.67 489.84 1236.12 489.115C1235.58 488.38 1235.28 487.443 1235.22 486.302H1238.52C1238.65 487.114 1238.97 487.689 1239.5 488.027C1240.03 488.366 1240.68 488.535 1241.45 488.535C1242.01 488.535 1242.51 488.482 1242.95 488.375C1243.39 488.259 1243.74 488.071 1243.99 487.81C1244.25 487.539 1244.38 487.177 1244.38 486.722C1244.38 486.403 1244.31 486.142 1244.16 485.939C1244.03 485.727 1243.82 485.543 1243.53 485.388C1243.25 485.234 1242.89 485.089 1242.45 484.953C1242.03 484.818 1241.54 484.668 1240.97 484.504C1239.97 484.214 1239.06 483.871 1238.23 483.474C1237.41 483.078 1236.76 482.561 1236.28 481.923C1235.79 481.275 1235.55 480.434 1235.55 479.4C1235.55 477.989 1236.07 476.887 1237.12 476.094C1238.16 475.292 1239.51 474.89 1241.15 474.89C1242.21 474.89 1243.17 475.045 1244.02 475.355C1244.88 475.654 1245.59 476.157 1246.14 476.862C1246.69 477.558 1247.05 478.506 1247.21 479.704L1243.9 479.69C1243.76 479.129 1243.55 478.699 1243.27 478.399C1242.99 478.09 1242.66 477.877 1242.29 477.761C1241.94 477.636 1241.54 477.573 1241.12 477.573C1240.66 477.573 1240.25 477.645 1239.92 477.79C1239.58 477.935 1239.32 478.138 1239.13 478.399C1238.95 478.66 1238.86 478.975 1238.86 479.342C1238.86 479.767 1238.98 480.125 1239.22 480.415C1239.47 480.695 1239.84 480.942 1240.34 481.154C1240.84 481.357 1241.46 481.57 1242.21 481.792C1242.81 481.966 1243.43 482.16 1244.06 482.372C1244.7 482.575 1245.3 482.836 1245.85 483.155C1246.4 483.474 1246.84 483.9 1247.18 484.431C1247.52 484.953 1247.69 485.635 1247.69 486.476C1247.69 487.974 1247.12 489.144 1245.99 489.985C1244.87 490.826 1243.38 491.247 1241.53 491.247ZM1257.52 491.276C1255.96 491.276 1254.61 490.932 1253.49 490.246C1252.37 489.55 1251.51 488.583 1250.91 487.346C1250.32 486.109 1250.03 484.673 1250.03 483.039C1250.03 481.319 1250.33 479.849 1250.94 478.631C1251.55 477.413 1252.4 476.485 1253.48 475.847C1254.56 475.2 1255.81 474.876 1257.22 474.876C1258.62 474.876 1259.8 475.137 1260.74 475.659C1261.7 476.171 1262.42 476.862 1262.89 477.732C1263.36 478.593 1263.58 479.555 1263.54 480.618H1260.25C1260.24 480.193 1260.17 479.806 1260.05 479.458C1259.92 479.1 1259.73 478.801 1259.48 478.559C1259.24 478.308 1258.93 478.114 1258.55 477.979C1258.18 477.844 1257.74 477.776 1257.23 477.776C1255.88 477.766 1254.92 478.23 1254.35 479.168C1253.79 480.106 1253.51 481.372 1253.51 482.967C1253.51 484.784 1253.85 486.142 1254.52 487.041C1255.21 487.931 1256.28 488.38 1257.73 488.39C1258.07 488.39 1258.43 488.293 1258.83 488.1C1259.23 487.897 1259.58 487.612 1259.86 487.244C1260.15 486.867 1260.29 486.418 1260.28 485.896H1263.54C1263.58 487.008 1263.31 487.965 1262.74 488.767C1262.18 489.569 1261.44 490.188 1260.51 490.623C1259.58 491.058 1258.59 491.276 1257.52 491.276ZM1266.62 491V475.18H1269.55L1269.93 481.27L1269.62 480.429C1269.69 479.791 1269.81 479.144 1270 478.486C1270.19 477.829 1270.46 477.225 1270.81 476.674C1271.17 476.123 1271.62 475.683 1272.17 475.355C1272.73 475.016 1273.42 474.847 1274.22 474.847C1274.41 474.847 1274.6 474.857 1274.8 474.876C1274.99 474.895 1275.17 474.929 1275.33 474.977V478.631C1275.01 478.525 1274.65 478.457 1274.28 478.428C1273.91 478.39 1273.57 478.37 1273.26 478.37C1272.88 478.37 1272.48 478.448 1272.04 478.602C1271.61 478.747 1271.21 478.97 1270.84 479.269C1270.47 479.569 1270.21 479.941 1270.04 480.386V491H1266.62ZM1283.86 491.218C1282.4 491.218 1281.12 490.903 1280.04 490.275C1278.96 489.647 1278.12 488.723 1277.52 487.505C1276.92 486.278 1276.62 484.775 1276.62 482.996C1276.62 481.314 1276.93 479.864 1277.56 478.646C1278.2 477.428 1279.07 476.495 1280.17 475.847C1281.27 475.19 1282.52 474.861 1283.91 474.861C1285.42 474.861 1286.71 475.19 1287.79 475.847C1288.87 476.495 1289.7 477.428 1290.28 478.646C1290.86 479.864 1291.15 481.314 1291.15 482.996C1291.15 484.775 1290.83 486.278 1290.18 487.505C1289.54 488.723 1288.67 489.647 1287.57 490.275C1286.47 490.903 1285.23 491.218 1283.86 491.218ZM1283.91 488.303C1285.03 488.303 1285.93 487.887 1286.64 487.056C1287.35 486.225 1287.7 484.871 1287.7 482.996C1287.7 481.256 1287.36 479.951 1286.67 479.081C1285.98 478.211 1285.04 477.776 1283.86 477.776C1282.74 477.776 1281.84 478.206 1281.13 479.066C1280.43 479.927 1280.09 481.237 1280.09 482.996C1280.09 484.784 1280.44 486.118 1281.14 486.998C1281.86 487.868 1282.78 488.303 1283.91 488.303ZM1294.4 491V468.438H1297.82V491H1294.4ZM1302.3 491V468.438H1305.73V491H1302.3ZM1317.56 491.174C1316.52 491.174 1315.69 491 1315.07 490.652C1314.45 490.304 1314 489.898 1313.71 489.434C1313.42 488.96 1313.23 488.545 1313.15 488.187L1312.4 487.505L1313.34 487.099C1313.41 487.341 1313.56 487.578 1313.79 487.81C1314.03 488.032 1314.37 488.216 1314.81 488.361C1315.25 488.496 1315.8 488.564 1316.45 488.564C1317.53 488.564 1318.42 488.143 1319.13 487.302C1319.83 486.461 1320.19 485.065 1320.19 483.112C1320.19 481.353 1319.85 480.028 1319.19 479.139C1318.53 478.24 1317.69 477.79 1316.66 477.79C1315.94 477.79 1315.34 477.892 1314.87 478.095C1314.4 478.298 1314.05 478.535 1313.81 478.805C1313.57 479.076 1313.41 479.318 1313.34 479.53L1313.13 479.327L1313.36 478.776C1313.41 478.042 1313.59 477.384 1313.91 476.804C1314.24 476.215 1314.72 475.746 1315.36 475.398C1316.01 475.05 1316.82 474.876 1317.81 474.876C1319.09 474.876 1320.16 475.219 1321.03 475.905C1321.9 476.582 1322.56 477.515 1323 478.704C1323.45 479.883 1323.68 481.246 1323.68 482.793C1323.68 484.195 1323.51 485.422 1323.16 486.476C1322.82 487.52 1322.36 488.39 1321.77 489.086C1321.19 489.782 1320.54 490.304 1319.81 490.652C1319.09 491 1318.34 491.174 1317.56 491.174ZM1309.96 491L1309.95 468.438H1313.36V475.615L1313.37 487.433L1313.62 487.984L1313.34 488.549L1313.2 491H1309.96ZM1331.3 491.174C1330.33 491.174 1329.47 490.995 1328.73 490.637C1327.99 490.27 1327.4 489.763 1326.97 489.115C1326.56 488.467 1326.35 487.718 1326.35 486.867C1326.35 485.93 1326.52 485.156 1326.86 484.547C1327.2 483.938 1327.69 483.455 1328.32 483.097C1328.97 482.73 1329.73 482.45 1330.6 482.256C1331.22 482.121 1331.87 482.01 1332.56 481.923C1333.25 481.836 1333.9 481.768 1334.49 481.72C1335.08 481.662 1335.53 481.623 1335.85 481.604V480.966C1335.85 479.893 1335.63 479.091 1335.2 478.559C1334.77 478.018 1334.05 477.747 1333.02 477.747C1332.36 477.747 1331.81 477.829 1331.37 477.993C1330.92 478.148 1330.59 478.448 1330.35 478.892C1330.13 479.327 1330.01 479.965 1329.99 480.806H1326.87C1326.77 479.443 1326.96 478.327 1327.45 477.457C1327.96 476.577 1328.7 475.93 1329.69 475.514C1330.68 475.089 1331.86 474.876 1333.21 474.876C1334.01 474.876 1334.77 474.968 1335.47 475.151C1336.19 475.325 1336.82 475.63 1337.37 476.065C1337.92 476.49 1338.36 477.075 1338.68 477.819C1339 478.564 1339.15 479.506 1339.15 480.647V491H1335.81L1335.85 487.447C1335.67 488.52 1335.2 489.41 1334.46 490.115C1333.71 490.821 1332.66 491.174 1331.3 491.174ZM1332.21 488.593C1332.71 488.593 1333.22 488.506 1333.73 488.332C1334.25 488.158 1334.71 487.907 1335.09 487.578C1335.49 487.249 1335.74 486.863 1335.85 486.418V483.518C1335.46 483.557 1335 483.624 1334.47 483.721C1333.95 483.818 1333.5 483.905 1333.12 483.982C1332.04 484.204 1331.26 484.499 1330.77 484.866C1330.3 485.224 1330.06 485.775 1330.06 486.519C1330.06 486.945 1330.16 487.317 1330.35 487.636C1330.56 487.945 1330.82 488.182 1331.15 488.346C1331.48 488.511 1331.83 488.593 1332.21 488.593ZM1343.37 491V475.18H1346.3L1346.67 481.27L1346.37 480.429C1346.44 479.791 1346.56 479.144 1346.75 478.486C1346.94 477.829 1347.21 477.225 1347.56 476.674C1347.92 476.123 1348.37 475.683 1348.92 475.355C1349.48 475.016 1350.16 474.847 1350.97 474.847C1351.16 474.847 1351.35 474.857 1351.55 474.876C1351.74 474.895 1351.92 474.929 1352.08 474.977V478.631C1351.75 478.525 1351.4 478.457 1351.02 478.428C1350.66 478.39 1350.32 478.37 1350.01 478.37C1349.63 478.37 1349.23 478.448 1348.79 478.602C1348.36 478.747 1347.95 478.97 1347.59 479.269C1347.22 479.569 1346.95 479.941 1346.79 480.386V491H1343.37Z" fill="white"/>
<path d="M1089.5 481H1225.5" stroke="#2CFF80" stroke-width="4"/>
<path d="M1087.5 266H1225.5" stroke="#2CFF80" stroke-width="4"/>
<path d="M244.5 162H324" stroke="#2CFF80" stroke-width="4"/>
<path d="M250 310.5H351" stroke="#2CFF80" stroke-width="4"/>
<path d="M307 366V576.5" stroke="#2CFF80" stroke-width="4"/>
<path d="M253 474H307" stroke="#2CFF80" stroke-width="4"/>
<rect x="465" y="219" width="505" height="40" fill="white" fill-opacity="0.2"/>
<rect x="465" y="288" width="177" height="40" fill="white" fill-opacity="0.2"/>
</svg>
`

/* -----------------------------------------------------------------------------
 * Implementation
 * -----------------------------------------------------------------------------*/

function toDashCase(str) {
  return str
    .replace(/([A-Z])/g, "-$1")
    .replace(/^-/, "")
    .toLowerCase()
}

const dashName = toDashCase(name)

const defaultPalette = {
  0: "white",
  1: "#2CFF80", //accentColor
  2: "#2C7A51",
  3: "#16402D",
  4: "#1C4D37",
  5: "#287753",
  6: "#1F8B56",
  7: "#2AB26B",
  8: "#1E6943",
  9: "#C1FFDF",
  10: "#41B883",
  11: "#299464",
  12: "#2AB36B",
  13: "#9FFFCD",
  14: "#0E432B",
  15: "#D9D9D9",
}

function findColors(code) {
  const pattern = /"#.*?"/g
  const matches = code.match(pattern) || []
  return Array.from(new Set(matches.map((match) => match.slice(1, -1))))
}

function replaceColors(code) {
  const colors = findColors(code)

  if (colors.length === 0) {
    return code.replaceAll(`"white"`, `{palette[0]}`)
  }

  const regex = new RegExp(
    colors
      .map((c) => `"${c}"`)
      .map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
      .join("|"),
    "g",
  )

  return code
    .replace(regex, (c) => {
      const num = Object.entries(defaultPalette).find((cc) => `"${cc[1]}"` === c)
      return `{palette[${num?.[0]}]}`
    })
    .replaceAll(`"white"`, `{palette[0]}`)
}

const jsxCode = transform.sync(svgCode, {
  plugins: ["@svgr/plugin-jsx"],
})

let template = `
import { createComponent } from "../create-component"

export const ${name}Anatomy = createComponent((props) => {
    const { palette, ...rest } = props
    return (
        ${jsxCode
          .replace('import * as React from "react";\n', "")
          .replace("const SvgComponent = props =>", "")
          .replace("export default SvgComponent;", "")
          .replace("{...props}", "{...rest}")
          .replace("</svg>;", "</svg>")}
    )
})
`

template = await format(replaceColors(template), { parser: "typescript" })

if (process.argv.includes("--dry-run")) {
  console.log(template)
  process.exit(0)
}

writeFileSync(`./src/components/${dashName}.tsx`, template, "utf-8")

const content = readFileSync("./src/components/index.ts", "utf-8").replace(
  "\n\nexport const allComponents = {",
  `
import { ${name}Anatomy } from "./${dashName}"

export const allComponents = {
 "${dashName}": ${name}Anatomy,`,
)

writeFileSync("./src/components/index.ts", content, "utf-8")
